home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Macintosh Tracker 1.1 Source / Original Tracker 3.10 Source / extern.h < prev    next >
Text File  |  1993-05-22  |  7KB  |  361 lines

  1. /* extern.h */
  2.  
  3. /* $Id: extern.h,v 3.8 1993/01/15 14:00:28 espie Exp espie $
  4.  * $Log: extern.h,v $
  5.  * Revision 3.8  1993/01/15  14:00:28  espie
  6.  * Added bg/fg test.
  7.  *
  8.  * Revision 3.7  1992/12/03  15:00:50  espie
  9.  * stty_sane.
  10.  *
  11.  * Revision 3.6  1992/11/27  10:29:00  espie
  12.  * General cleanup
  13.  *
  14.  * Revision 3.5  1992/11/24  10:51:19  espie
  15.  * New audio functions.
  16.  *
  17.  * Revision 3.4  1992/11/23  17:18:59  espie
  18.  * *** empty log message ***
  19.  *
  20.  * Revision 3.3  1992/11/23  10:12:23  espie
  21.  * *** empty log message ***
  22.  *
  23.  * Revision 3.2  1992/11/22  17:20:01  espie
  24.  * Simplified delay_pattern.
  25.  *
  26.  * Revision 3.1  1992/11/19  20:44:47  espie
  27.  * Protracker commands.
  28.  *
  29.  * Revision 3.0  1992/11/18  16:08:05  espie
  30.  * New release.
  31.  *
  32.  * Revision 2.19  1992/11/17  17:06:25  espie
  33.  * Lots of new functions to account for new interface.
  34.  * open_file support.
  35.  * Separated mix/stereo stuff.
  36.  * Added possibility to get back to MONO for the sgi.
  37.  * Added stereo capabilities to the indigo version.
  38.  * Added some new song types to automatize the choice process.
  39.  * Moved resampling to audio, added prototype.
  40.  * Added SAMPLE_FAULT, for trying to play
  41.  * a note without a sample (not really an error).
  42.  *
  43.  * Revision 1.7  1991/11/08  14:25:55  espie
  44.  * Modified audio prototype so that you can change
  45.  * frequency.
  46.  * Added prototype for release_song.
  47.  * Added arpeggio effect.
  48.  * Added entries for new effects.
  49.  * Added entries for commands.c.
  50.  */
  51.  
  52.  
  53.  
  54.  
  55.  
  56. /* audio.c */
  57. #define ACCURACY 12
  58. #define fix_to_int(x) ((x) >> ACCURACY)
  59. #define int_to_fix(x) ((x) << ACCURACY)
  60.  
  61. /* init_tables(oversample, frequency, chan):
  62.  * precomputes the step_table and the pitch_table
  63.  * according to the desired oversample and frequency.
  64.  * This is static, you can call it again whenever you want.
  65.  * adjusting current parameters of channel if needed.
  66.  */
  67. X void init_tables();
  68.  
  69. /* resample(chan, oversample, number):
  70.  * send number samples out computed according
  71.  * to the current state of chan[0:NUMBER_CHANNELS],
  72.  * and oversample.
  73.  */
  74. X void resample();
  75.  
  76. /* reset_note(ch, note, pitch):
  77.  * set channel ch to play note at pitch pitch
  78.  */
  79. X void reset_note();
  80.  
  81. /* set_current_pitch(ch, pitch):
  82.  * set channel ch to play at pitch pitch
  83.  */
  84. X void set_current_pitch();
  85.  
  86. /* set_current_volume(ch, volume):
  87.  * set channel ch to play at volume volume
  88.  */
  89. X void set_current_volume();
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. /* automaton.c */
  98. /* init_automaton(a, song):
  99.  * put the automaton a in the right state to play song.
  100.  */
  101. X void init_automaton();
  102. /* next_tick(a):
  103.  * set up everything for the next tick.
  104.  */
  105. X void next_tick();
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113. /* commands.c */
  114. /* init_effects(): sets up all data for the effects */
  115. X void init_effects();
  116. /* do_nothing: this is the default behavior for an effect.
  117.  */
  118. X void do_nothing();
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127. /* dump_song */
  128. /* dump_song(s): 
  129.  * displays some information pertinent to the given 
  130.  * song s.
  131.  */
  132. X void dump_song();
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. /* getopt.c */
  141. /* n = getopt(argc, argv, options):
  142.  * try to parse options out of argv, using
  143.  * ways similar to standard getopt
  144.  */
  145. X int getopt();
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152. /* main.c */
  153. #define OLD 0
  154. #define NEW 1
  155. /* special new type: for when we try to read it as both types.
  156.  */
  157. #define BOTH 2
  158. /* special type: does not check the signature */
  159. #define NEW_NO_CHECK 3
  160.  
  161.  
  162. /* error types. Everything is centralized,
  163.  * and we check in some places (see read, player and str32)
  164.  * that there was no error. Additionnally signal traps work
  165.  * that way too.
  166.  */
  167.  
  168. /* normal state */
  169. #define NONE 0  
  170. /* read error */
  171. #define FILE_TOO_SHORT 1
  172. #define CORRUPT_FILE 2
  173. /* trap error: goto next song right now */
  174. #define NEXT_SONG 3
  175. /* run time problem */
  176. #define FAULT 4
  177. /* the song has ended */
  178. #define ENDED 5
  179. /* unrecoverable problem: typically, trying to 
  180.  * jump to nowhere land.
  181.  */
  182. #define UNRECOVERABLE 6
  183. /* Missing sample. Very common error, not too serious. */
  184. #define SAMPLE_FAULT 7
  185. /* New */
  186. #define PREVIOUS_SONG 8
  187. X int error;
  188.  
  189. /* end_all(): faaaast exit */
  190. X void end_all();
  191.  
  192.  
  193.  
  194.  
  195. /* notes.c */
  196. #define NUMBER_NOTES 120
  197. #define NUMBER_FINETUNES 17
  198. X int pitch_table[NUMBER_NOTES][NUMBER_FINETUNES];
  199. X char note_name[NUMBER_NOTES][4];
  200. /* create_notes_table():
  201.  * build the correspondance pitch -> note
  202.  */
  203. X void create_notes_table();
  204. /* note = find_note(pitch):
  205.  * find note corresponding to a given pitch
  206.  */
  207. X int find_note();
  208. /* oldtranspose = transpose_song(song, newtranspose):
  209.  * tranpose song to a new pitch
  210.  */
  211. X int transpose_song();
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218. /* open.c */
  219. /* handle = open_file(filename, mode, path):
  220.  * transparently open a compressed file.
  221.  */
  222. X FILE *open_file();
  223.  
  224. /* close_file(handle):
  225.  * close a file that was opened with open_file.
  226.  */
  227. X void close_file();
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234. /* player.c */
  235. /* init_player(oversample, frequency):
  236.  * sets up the player for a given oversample and
  237.  * output frequency.
  238.  * Note: we can call init_player again to change oversample and
  239.  * frequency.
  240.  */
  241. X void init_player();
  242.  
  243. /* play_song(song, pref):
  244.  * plays the song according to the current pref.
  245.  */
  246. X void play_song();
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. /* read.c */
  255. /* s = read_song(f, type):
  256.  * tries to read f as a song of type NEW/OLD.
  257.  * returns NULL (and an error) if it doesn't work.
  258.  * Returns a dynamic song structure if successful.
  259.  */
  260. X struct song *read_song();
  261.  
  262. /* release_song(s):
  263.  * release all the memory song occupies.
  264.  */
  265. X void release_song();
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273. /* setup_audio.c */
  274. /* setup_audio(ask_freq, stereo, oversample, sync):
  275.  * setup the audio output with these values 
  276.  */
  277. X void setup_audio();
  278. /* do_close_audio():
  279.  * close audio only if needed
  280.  */
  281. X void do_close_audio();
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289. /* xxx_audio.c */
  290. /* frequency = open_audio(f, s):
  291.  * try to open audio with a sampling rate of f, and eventually stereo.
  292.  * We get the real frequency back. If we ask for 0, we
  293.  * get the ``preferred'' frequency.
  294.  * Note: we have to close_audio() before we can open_audio() again.
  295.  * Note: even if we don't ask for stereo, we still have to give a
  296.  * right and left sample.
  297.  */
  298. X int open_audio();
  299. /* close_audio():
  300.  * returns the audio to the system control, doing necessary
  301.  * cleanup
  302.  */
  303. X void close_audio();
  304. /* set_mix(percent): set mix channels level.
  305.  * 0: spatial stereo. 100: mono.
  306.  */
  307. X void set_mix();
  308. /* output_samples(l, r): outputs a pair of stereo samples.
  309.  * Samples are 15 bits signed.
  310.  */
  311. X void output_samples();
  312. /* flush_buffer(): call from time to time, because buffering
  313.  * is done by the program to get better (?) performance.
  314.  */
  315. X void flush_buffer();
  316. /* discard_buffer(): try to get rid of the buffer contents
  317.  */
  318. X void discard_buffer();
  319. /* new_freq = update_frequency():
  320.  * if !0, frequency changed and playing should be updated accordingly
  321.  */
  322. X int update_frequency();
  323. /* set_synchro(bool):
  324.  * try to synchronize audio output by using a smaller buffer
  325.  */
  326. X void set_synchro();
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. /* termio.c */
  335. /* nonblocking_io():
  336.  * try to setup the keyboard to non blocking io
  337.  */
  338. X void nonblocking_io();
  339. X void sane_tty();
  340. /* may_getchar():
  341.  * return EOF, or a char if available
  342.  */
  343. X int may_getchar();
  344. /* run_in_fg():
  345.  * try to decide whether or not we're currently running in the foreground.
  346.  */
  347. X BOOL run_in_fg();
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355. /* tools.c */
  356. /* v = read_env(name, default):
  357.  * read a scalar value in the environment
  358.  */
  359. X int read_env();
  360.  
  361.